package com.jiaoxn.example.service.impl;

import com.jiaoxn.example.dao.CompanyDAO;
import com.jiaoxn.example.entity.CompanyDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jiaoxn.example.service.CompanyService;

import java.util.Date;

/**
 * @author jiao xn
 * @date 2022/8/25
 */
@Service
public class CompanyServiceImpl implements CompanyService {
    private final CompanyDAO companyDAO;

    @Autowired
    public CompanyServiceImpl(CompanyDAO companyDAO) {
        this.companyDAO = companyDAO;
    }

    @Override
    public CompanyDO queryById(Integer id) {
        return companyDAO.queryById(id);
    }

    @Override
    public Integer insertCompany(String companyName) {
        CompanyDO companyDO = new CompanyDO();
        companyDO.setName(companyName);
        companyDO.setIsDeleted("0");
        companyDO.setGmtCreate(new Date());
        companyDO.setGmtModified(new Date());

        companyDAO.insertCompany(companyDO);

        return companyDO.getId();
    }
}
